

from core.himesis import Himesis, HimesisPreConditionPatternLHS
import cPickle as pickle
from uuid import UUID

class HFindTwoStationsWithBackwardLHS(HimesisPreConditionPatternLHS):
    def __init__(self):
        """
        Creates the himesis graph representing the AToM3 model HFindTwoStationsWithBackwardLHS.
        """
        # Flag this instance as compiled now
        self.is_compiled = True
        
        super(HFindTwoStationsWithBackwardLHS, self).__init__(name='HFindTwoStationsWithBackwardLHS', num_nodes=14, edges=[])
        
        # Add the edges
        self.add_edges([(8, 0), (5, 0), (9, 1), (4, 1), (10, 2), (2, 12), (11, 3), (3, 13), (13, 4), (12, 5), (6, 8), (7, 9)])
        # Set the graph attributes
        self["mm__"] = pickle.loads("""(lp1
S'MT_pre__SimpleDSLTrans'
p2
aS'MoTifRule'
p3
a.""")
        self["MT_constraint__"] = """#===============================================================================
# This code is executed after the nodes in the LHS have been matched.
# You can access a matched node labelled n by: PreNode('n').
# To access attribute x of node n, use: PreNode('n')['x'].
# The given constraint must evaluate to a boolean expression:
#    returning True enables the rule to be applied,
#    returning False forbids the rule from being applied.
#===============================================================================

return True
"""
        self["name"] = """"""
        self["GUID__"] = UUID('aad349f8-db3d-4259-86df-2598bdcbac91')
        
        # Set the node attributes
        self.vs[0]["MT_subtypeMatching__"] = False
        self.vs[0]["MT_label__"] = """5"""
        self.vs[0]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[0]["mm__"] = """MT_pre__Station_S"""
        self.vs[0]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[0]["MT_dirty__"] = False
        self.vs[0]["GUID__"] = UUID('927d03d9-b30c-4208-a1e8-d6a4390515c4')
        self.vs[1]["MT_pivotOut__"] = """stationMatch2"""
        self.vs[1]["MT_subtypeMatching__"] = False
        self.vs[1]["MT_label__"] = """6"""
        self.vs[1]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[1]["mm__"] = """MT_pre__Station_S"""
        self.vs[1]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[1]["MT_dirty__"] = False
        self.vs[1]["GUID__"] = UUID('04afa20d-04af-47c1-9fb2-0c7f6901b282')
        self.vs[2]["MT_subtypeMatching__"] = False
        self.vs[2]["MT_label__"] = """10"""
        self.vs[2]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[2]["mm__"] = """MT_pre__apply_contains"""
        self.vs[2]["MT_dirty__"] = False
        self.vs[2]["GUID__"] = UUID('aab68876-4a3e-4711-89a1-2e482bc4bb53')
        self.vs[3]["MT_subtypeMatching__"] = False
        self.vs[3]["MT_label__"] = """11"""
        self.vs[3]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[3]["mm__"] = """MT_pre__apply_contains"""
        self.vs[3]["MT_dirty__"] = False
        self.vs[3]["GUID__"] = UUID('d1ad4251-ddc0-4a0a-ab1a-b2aa6f7bee31')
        self.vs[4]["MT_subtypeMatching__"] = False
        self.vs[4]["MT_label__"] = """13"""
        self.vs[4]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[4]["mm__"] = """MT_pre__backward_link"""
        self.vs[4]["MT_dirty__"] = False
        self.vs[4]["GUID__"] = UUID('c28d8e6a-d286-4adb-b3b7-d8d88a7bddec')
        self.vs[5]["MT_subtypeMatching__"] = False
        self.vs[5]["MT_label__"] = """14"""
        self.vs[5]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[5]["mm__"] = """MT_pre__backward_link"""
        self.vs[5]["MT_dirty__"] = False
        self.vs[5]["GUID__"] = UUID('81de54c2-400d-45a7-98ab-d802a0539b3b')
        self.vs[6]["MT_subtypeMatching__"] = False
        self.vs[6]["MT_label__"] = """1"""
        self.vs[6]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[6]["mm__"] = """MT_pre__MatchModel"""
        self.vs[6]["MT_dirty__"] = False
        self.vs[6]["GUID__"] = UUID('3767eea5-a669-4f00-aa8c-3e3ddd9a378a')
        self.vs[7]["MT_subtypeMatching__"] = False
        self.vs[7]["MT_label__"] = """2"""
        self.vs[7]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[7]["mm__"] = """MT_pre__MatchModel"""
        self.vs[7]["MT_dirty__"] = False
        self.vs[7]["GUID__"] = UUID('ff4e1f2a-c3de-4652-b44c-dc9bc79b9b51')
        self.vs[8]["MT_subtypeMatching__"] = False
        self.vs[8]["MT_label__"] = """9"""
        self.vs[8]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[8]["mm__"] = """MT_pre__match_contains"""
        self.vs[8]["MT_dirty__"] = False
        self.vs[8]["GUID__"] = UUID('a3aa3d2d-9e26-435f-bcf0-9411a20deb8b')
        self.vs[9]["MT_subtypeMatching__"] = False
        self.vs[9]["MT_label__"] = """12"""
        self.vs[9]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[9]["mm__"] = """MT_pre__match_contains"""
        self.vs[9]["MT_dirty__"] = False
        self.vs[9]["GUID__"] = UUID('1609e6c2-405a-4626-aaf0-239e9434ce98')
        self.vs[10]["MT_subtypeMatching__"] = False
        self.vs[10]["MT_label__"] = """3"""
        self.vs[10]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[10]["mm__"] = """MT_pre__ApplyModel"""
        self.vs[10]["MT_dirty__"] = False
        self.vs[10]["GUID__"] = UUID('df03ed81-4142-471c-a6b8-82204f823d0e')
        self.vs[11]["MT_subtypeMatching__"] = False
        self.vs[11]["MT_label__"] = """4"""
        self.vs[11]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[11]["mm__"] = """MT_pre__ApplyModel"""
        self.vs[11]["MT_dirty__"] = False
        self.vs[11]["GUID__"] = UUID('25612ed1-c20e-45b1-b416-effbbe5ef49e')
        self.vs[12]["MT_pivotOut__"] = """stationApply1"""
        self.vs[12]["MT_subtypeMatching__"] = False
        self.vs[12]["MT_label__"] = """7"""
        self.vs[12]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[12]["mm__"] = """MT_pre__Station_T"""
        self.vs[12]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[12]["MT_dirty__"] = False
        self.vs[12]["GUID__"] = UUID('983323aa-8e57-42f8-8b5d-d7336e963c55')
        self.vs[13]["MT_pivotOut__"] = """stationApply2"""
        self.vs[13]["MT_subtypeMatching__"] = False
        self.vs[13]["MT_label__"] = """8"""
        self.vs[13]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[13]["mm__"] = """MT_pre__Station_T"""
        self.vs[13]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[13]["MT_dirty__"] = False
        self.vs[13]["GUID__"] = UUID('d8d1ac72-e175-4fc0-8ebd-da3426bfb74f')

    def eval_name5(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_name6(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_name7(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_name8(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def constraint(self, PreNode, graph):
        """
            Executable constraint code. 
            @param PreNode: Function taking an integer as parameter
                            and returns the node corresponding to that label.
        """
        #===============================================================================
        # This code is executed after the nodes in the LHS have been matched.
        # You can access a matched node labelled n by: PreNode('n').
        # To access attribute x of node n, use: PreNode('n')['x'].
        # The given constraint must evaluate to a boolean expression:
        #    returning True enables the rule to be applied,
        #    returning False forbids the rule from being applied.
        #===============================================================================
        
        return True

